package com.han.yrpc.registrycenter.localcache;

import com.han.yrpc.core.registry.Register;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Component
public class LocalcacheRegister implements Register {

    private final int DEFAULT_PORT = 10001;
    private int PORT = DEFAULT_PORT;

    @Override
    public int getPort() {
        return PORT;
    }

    @Override
    public String getHost() {
        try {
            return InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return "127.0.0.1";
    }
}
